/**
 * @UiWindow.hpp
 * Copyright 2013 (C) FatalEror / Dean Bahari
 * 
 * UiPack is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * See LICENSE file in main folder for more information.
 */

#ifndef _UI_WINDOW_HPP_
#define _UI_WINDOW_HPP_

#define UI_WINDOWSIZE_TITLE 25
#define UI_WINDOWSIZE_BORDER 8

class UiMenubar;
class UiSizer;

class UiBaseWindow : public UiBase {
protected:
	std::wstring  mTitle;
	int           mState;
	int           mSysState;
public:
	UiBaseWindow(const wchar_t *title, int width, int height, int x = 0, int y = 0);
	~UiBaseWindow();

	void setTitle(const wchar_t *title);

	const wchar_t *getTitle();
	int            getState();

	enum State {
		UI_WINDOW_MAXIMIZED = 0x01,
		UI_WINDOW_MINIMIZED = 0x02,
		UI_WINDOW_RESTORED  = 0x04,
		UI_WINDOW_DISABLED  = 0x08,

		UI_SYS_RESIZE       = 0x01,
		UI_SYS_MINIMIZE     = 0x02,
		UI_SYS_CLOSE        = 0x04,
		UI_SYS_HOVER        = 0x10,
		UI_SYS_CLICK        = 0x20,
	};

	void show();
protected:
	virtual void onMinimize(UiEvent &ev);
	virtual void onResize(UiEvent &ev);
	virtual void onClose(UiEvent &ev);
	virtual void onRestore(UiEvent &ev);
	virtual LRESULT CALLBACK handleCustomProc(UINT msg, WPARAM wParam, LPARAM lParam);
};

class UiWindow : public UiBaseWindow {
	POINT        *mMinSize;
	POINT        *mMaxSize;
	UiMenubar    *mMenubar;
public:
	UiWindow(const wchar_t *title, int width, int height, int x = 0, int y = 0);
	~UiWindow();

	void setMinSize(short width, short height);
	void setMaxSize(short width, short height);
	void setMenubar(UiMenubar *menubar);
	virtual void setSizer(UiSizer *newSizer);
protected:
	virtual LRESULT CALLBACK handleCustomProc(UINT msg, WPARAM wParam, LPARAM lParam);
};

class UiToolWindow : public UiBaseWindow {
	bool mAttached;
	bool mFocused;
public:
	UiToolWindow(const wchar_t *title, int width, int height, int x = 0, int y = 0);

	void setOwner(UiWindow *owner);
	void mainFocus(bool isFocus = true);

	friend class UiSizer;
protected:
	virtual LRESULT CALLBACK handleCustomProc(UINT msg, WPARAM wParam, LPARAM lParam);
};

#endif//_UI_WINDOW_HPP_